package jeeditor;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Servlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6622421398254247856L;

	private static final String JSP_PATH = "/WEB-INF/jsp";

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String uri = request.getRequestURI();
		String contextpath = request.getContextPath();
		request.setAttribute("contextpath", contextpath);
		if (uri.equalsIgnoreCase(contextpath + "/index.html")) {
			this.indexServlet(request, response);
		}
	}

	private void indexServlet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		RequestDispatcher dispatcher = request.getRequestDispatcher(JSP_PATH + "/index.jsp");
		dispatcher.forward(request, response);
	}

}
